<%--
  Created by IntelliJ IDEA.
  User: xuweijie
  Date: 17-5-9
  Time: 下午1:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/header.jsp" %>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>全部角色</legend>
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row">
    <colgroup>
        <col width="80">
        <col width="200">
        <col width="350">
        <col width="850">
        <col width="200">
    </colgroup>
    <thead>
    <tr>
        <th>序号</th>
        <th>角色</th>
        <th>描述</th>
        <th>拥有权限</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:set var="i" value="${0}"/>
    <c:forEach items="${roles}" var="role">
        <tr>
            <c:set var="i" value="${i+1}"/>
            <td>${i}</td>
            <td>${role.rolename}</td>
            <td>${role.description}</td>
            <td>
                <c:set var="j" value="${0}"/>
                <c:forEach items="${role.roots}" var="root">
                <c:set var="j" value="${j+1}"/>
                <c:if test="${j%2==0}">
                    <button name="roots" class="layui-btn layui-btn-radius layui-btn-normal" value="${root.croRoot.id}">
                </c:if>
                <c:if test="${j%2==1}">
                    <button name="roots" class="layui-btn layui-btn-radius" value="${root.croRoot.id}">
                </c:if>
                    ${root.croRoot.descript}</button>
                </c:forEach>
            </td>
            <td><a data-method="update" roleid="${role.id}" roots="${role.roots}"
                   class="layui-btn layui-btn-small layui-btn-normal updaterole"><i class="layui-icon"></i></a>
                &nbsp;&nbsp;
                <a data-method="notice" roleid="${role.id}"
                   class="layui-btn layui-btn-small layui-btn-danger delrole"><i class="layui-icon"></i></a></td>
        </tr>
    </c:forEach>
    </tbody>
</table>

<%--更新页面的样式--%>
<form id="updatemodel" class="layui-form" action="" hidden>
    <br>
    <input type="text" id="roleid" hidden>
    <div class="layui-form-item"><label class="layui-form-label">角色名称</label>
        <div class="layui-input-block">
            <input type="text" id="ckrolename" name="ckrolename" required lay-verify="required" placeholder="请输入角色名称"
                   autocomplete="off" class="layui-input" style="width: 95%"></div>
    </div>
    <div class="layui-form-item"><label class="layui-form-label">权限</label>
        <div class="layui-input-block" id="divroot">
            <c:forEach items="${croRoots}" var="roots">
                <input type="checkbox" name="ckroot" value="${roots.id}" title="${roots.descript}">
            </c:forEach>
        </div>
    </div>
    <div class="layui-form-item layui-form-text"><label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <textarea name="ckroledesc" id="ckroledesc" placeholder="请输入内容" class="layui-textarea"
                      style="width: 95%"></textarea></div>
    </div>
</form>
